1 public abstract class ConnectDaemon extends Thread {
2
3 public ConnectDaemon(boolean demon) {
4 setDaemon(demon);
5 }
6
7 public void run() {
8 HTTPDaemon httpd;
9 Connection client;
10
11 System.out.println("ConnectDaemon: Im up.");
12
13 if (initialize()) {
14 httpd = new HTTPDaemon(8080);
15 httpd.setUseHostName(false);
16 System.out.println("Exposed: " + httpd.url());
17
18
19 while ((client = httpd.accept()) != null) {
20 handleConnection(client);
21 }
22 }
23 }
24
25 protected boolean initialize() {
26 return true;
27 }
28
29 protected abstract void handleConnection(Connection client);
30 }
31
|